# 导包
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By

# 创建浏览器对象并打开浏览器
driver = webdriver.Chrome()
driver.maximize_window()
driver.get("http://www.baidu.com")

# 元素定位+元素操作
test_dir = driver.find_element(By.XPATH, '//ul[contains(@class,"s-hot")]/li[2]/a/span[2]')
print(test_dir)

# current_url
print(driver.current_url)

# get_attribute("属性名")
button = driver.find_element(By.ID, 'su')
print(button.get_attribute("value"))

# is_display()
setting = driver.find_element(By.CSS_SELECTOR, 'span[name*="tj"]')
print(setting.is_displayed())

# is_enabled()
print(setting.is_enabled())

# 关闭浏览器
sleep(3)
driver.quit()